Skip to content

06: Conflict policy constants - #6

Open
nikolaystrikhar wants to merge 3 commits into
05-ci-static-analysisfrom
06-conflict-policy
Open

06: Conflict policy constants#6
nikolaystrikhar wants to merge 3 commits into
05-ci-static-analysisfrom
06-conflict-policy

Conversation

@nikolaystrikhar

@nikolaystrikhar nikolaystrikhar commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Adds the three conflict-policy string constants, plus all() and is_valid().

Stacked on #5.

'conflict_policy' => Conflict_Policy::DEACTIVATE,  // or DEFER, or NOTICE_ONLY
  • String constants, not an enum. PHP floor is 7.4. Not bare strings either, since a host may persist one in an option — so the test asserts the literal values, which are a public contract.
  • is_valid() closes a destructive default. Nothing validated a policy before: the resolver's default: fell into deactivate(), so 'defered' from a typo or someone else's filter would deactivate a plugin the site owner deliberately turned on. Unknown is now its own case, falling back to NOTICE_ONLY.
  • Constant set pinned by reflection. Catches an added fourth policy that the same default: would otherwise swallow.
  • DEACTIVATE description corrected in the README and docblock. The bundled copy does not load on that request — the standalone has already defined the guard constant before plugins_loaded, so the request ends at the redirect and the load happens next request.

@nikolaystrikhar nikolaystrikhar mentioned this pull request Aug 3, 2026
Nothing validated a policy string. The resolver switches on it with a
default branch that deactivates, so a typo or a stale filter return would
turn off a plugin the site owner deliberately activated -- the most
surprising of the three outcomes to arrive at by accident. all() and
is_valid() give callers a way to tell unknown from DEACTIVATE.

Also pin the constant set by reflection, so a fourth policy cannot be added
without the resolver's switch being revisited, and correct the DEACTIVATE
description: the bundled copy loads on the next request, not this one, since
the standalone has already defined the guard constant and the request ends
at the redirect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant